<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${phone.name}"></title>
    <script type="text/javascript" th:src="@{/jquery.3.6.0.js}"></script>
    <script type="text/javascript" th:inline="javascript">
        /*<![CDATA[*/
        ctxPath = /*[[@{/}]]*/ '';
        /*]]>*/
        console.info(ctxPath);
    </script>　
</head>
<body>
<li th:text="${phone.id}"></li>
<li th:text="${phone.name}"></li>
<li th:text="${phone.price}"></li>
<li>
    <a th:onclick="'javascript:doKill('+${phone.id}+')'" href="javascript:void(0)">秒杀</a>
</li>
</body>
<script>
    function doKill(id) {
        $.ajax({
           url:  '/kill/phone/kill/' + id,
           dataType: "json",
           success: function (res) {
               alert(res.msg)
               if (res.status) {
                    window.location.href = '/kill/order';
               }
           },
            error: function (res) {
                alert(res)
            }
        });
    }
</script>
</html>